package com.springStudy.core.profile;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.*;
import org.springframework.core.env.AbstractEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;

@Configuration
@ComponentScan(value = { "com.springStudy.core.profile.*" },excludeFilters =  {@ComponentScan.Filter(type = FilterType.ANNOTATION,value = Service.class)})
//@ActiveProfiles("dev") 基于spring测试框架可以用来指定运行环境
//@EnableCaching
public class ProfileAppConfigDemo {
    public static void main(String[] args) {
        System.setProperty(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME, "dev");
        ApplicationContext context = new AnnotationConfigApplicationContext(ProfileAppConfigDemo.class);
        String[] beanDefinitionNames = context.getBeanDefinitionNames();
        for (String beanName : beanDefinitionNames) {
            System.out.println(beanName + " : " + context.getBean(beanName));
        }
        Environment environment = context.getEnvironment();
        System.out.println(environment);


    }


}
